﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKArchMethodLibrary.Utils;
using StairsModuleAndEdit.StairsModel.CommonUnit;
using StairsModuleAndEdit.StairsModel.DataInfos;
using StairsModuleAndEdit.StairsModel.Kit;

namespace StairsModuleAndEdit.StairsModel.Form
{
	public partial class LinearDoubleBranceThreeRunStairsForm : EscBaseForm
	{
		public LinearDoubleBranceThreeRunStairsForm(ExternalCommandData cmdData)
		{
			this.m_Revit = cmdData;
			this.m_StairsDrawingKit = new DoubleBranceThreeRunStairsKit(this.m_Revit.Application.Application);
			this.m_ComponentTypeManager = new ComponentTypeManager(this.m_Revit.Application.ActiveUIDocument.Document);
			this.m_listAllLevels = new List<Level>(StairsModuleAndEdit.StairsModel.CommonUnit.Common.GetSortLevels(this.m_Revit.Application.ActiveUIDocument.Document, double.MinValue, double.MaxValue));
			this.m_listStairsData = new List<double>();
			this.InitializeComponent();
			this.m_MainPreviewer = new Previewer(this, this.pnlPreview.Left, this.pnlPreview.Top, this.pnlPreview.Width, this.pnlPreview.Height, 1u);
			this.pnlPreview.Visible = false;
			base.MouseWheel += this.m_MainPreviewer.MouseWheel;
		}

		public double TopOffset
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbTopOffset.Text, 0.0);
			}
			set
			{
				this.hyTbTopOffset.Text = value.ToString("f2");
			}
		}

		public double BottomOffset
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0);
			}
			set
			{
				this.hyTbBottomOffset.Text = value.ToString("f2");
			}
		}

		public double SideStairsWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbSideStairsWidth.Text);
			}
			set
			{
				this.hyTbSideStairsWidth.Text = value.ToString("f2");
			}
		}

		public double MiddleStairsWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbMiddleStairsWidth.Text);
			}
			set
			{
				this.hyTbMiddleStairsWidth.Text = value.ToString("f2");
			}
		}

		public double TwoRunStairsWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbTwoRunStairsWidth.Text);
			}
			set
			{
				this.hyTbTwoRunStairsWidth.Text = value.ToString("f2");
			}
		}

		public int TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudTreadCount.Value.ToString());
			}
			set
			{
				this.nudTreadCount.Value = value;
			}
		}

		public int SideTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudSideTreadCount.Value.ToString());
			}
			set
			{
				this.nudSideTreadCount.Value = value;
			}
		}

		public int MiddleTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudMidTreadCount.Value.ToString());
			}
			set
			{
				this.nudMidTreadCount.Value = value;
			}
		}

		public int TwoRunTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudTwoRunTreadCount.Value.ToString());
			}
			set
			{
				this.nudTwoRunTreadCount.Value = value;
			}
		}

		public double TreadHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadHeight.Text);
			}
			set
			{
				this.hyTbTreadHeight.Text = value.ToString("f2");
			}
		}

		public double TreadDepth
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadDepth.Text);
			}
			set
			{
				this.hyTbTreadDepth.Text = value.ToString("f2");
			}
		}

		public string UsingRange
		{
			get
			{
				return this.comboUsingRange.Text;
			}
		}

		public int RunStructualDepth
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(this.tbRunThickness.Text, 0);
			}
			set
			{
				this.tbRunThickness.Text = value.ToString();
			}
		}

		public int RunRiserThickness
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(this.tbRiserThickness.Text, 0);
			}
			set
			{
				this.tbRiserThickness.Text = value.ToString();
			}
		}

		public int TreadThickness
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(this.tbTreadThickness.Text, 0);
			}
			set
			{
				this.tbTreadThickness.Text = value.ToString();
			}
		}

		public double BeamWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamWidth.Text);
			}
			set
			{
				this.hyTbBeamWidth.Text = value.ToString("f2");
			}
		}

		public double BeamHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamHeight.Text);
			}
			set
			{
				this.hyTbBeamHeight.Text = value.ToString("f2");
			}
		}

		public double MiddleLandingLength
		{
			get
			{
				return Convert.ToDouble(this.hyTbMidLandingLength.Text);
			}
			set
			{
				this.hyTbMidLandingLength.Text = value.ToString("f2");
			}
		}

		public double MiddleLandingWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbMidLandingWidth.Text);
			}
			set
			{
				this.hyTbMidLandingWidth.Text = value.ToString("f2");
			}
		}

		public double SideLandingLength
		{
			get
			{
				return Convert.ToDouble(this.hyTbSideLandingLength.Text);
			}
			set
			{
				this.hyTbSideLandingLength.Text = value.ToString("f2");
			}
		}

		public double SideLandingWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbSideLandingWidth.Text);
			}
			set
			{
				this.hyTbSideLandingWidth.Text = value.ToString("f2");
			}
		}

		public int LandingThickness
		{
			get
			{
				return StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(this.tbLandThickness.Text, 0);
			}
			set
			{
				this.tbLandThickness.Text = value.ToString();
			}
		}

		public double RotateAngle
		{
			get
			{
				double num = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0);
				return num / 180.0 * Math.PI;
			}
			set
			{
				this.hyTbRotateAngle.Text = (value * 180.0 / Math.PI).ToString("f0");
			}
		}

		public XYZ BasePoint
		{
			get
			{
				return this.m_BasePoint;
			}
		}

		public LinearDoubleBranceThreeRunStairsForm.MeasureType theMeasureType
		{
			get
			{
				return this.m_MeasureType;
			}
		}

		public LineRunData GetSideStairsData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.RunWidth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideStairsWidth);
			lineRunData.TreadHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
			lineRunData.TreadCount = this.SideTreadCount;
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			if (!this.m_bCenterStart)
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation);
			}
			else
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)(this.MiddleTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight) + (double)(this.TwoRunTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			}
			lineRunData.TreadThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public LineRunData GetMiddleStairsData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.RunWidth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.MiddleStairsWidth);
			lineRunData.TreadHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
			lineRunData.TreadCount = this.MiddleTreadCount;
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			if (this.m_bCenterStart)
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation);
			}
			else
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)(this.SideTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight) + (double)(this.TwoRunTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			}
			lineRunData.TreadThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public LineRunData GetTwoRunStairsData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.RunWidth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TwoRunStairsWidth);
			lineRunData.TreadHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
			lineRunData.TreadCount = this.TwoRunTreadCount;
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			if (this.m_bCenterStart)
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)(this.MiddleTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			}
			else
			{
				lineRunData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)(this.SideTreadCount + 1) * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			}
			lineRunData.TreadThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public List<BaseRaillingData> GetRailingData()
		{
			List<BaseRaillingData> list = new List<BaseRaillingData>();
			List<string> heightsOfRailingTypeList = this.m_ComponentTypeManager.GetHeightsOfRailingTypeList();
			if (this.chkInnerRailing.Checked)
			{
				double num = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideStairsWidth);
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbInnerRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex),
					m_ptStart = new XYZ(num, 0.0, 0.0)
				});
				double num2 = 0.0;
				if (1E-09 < this.MiddleLandingWidth - this.MiddleStairsWidth)
				{
					num2 = (this.MiddleLandingWidth - this.MiddleStairsWidth) / 2.0;
				}
				num = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingLength + (double)this.TwoRunTreadCount * this.TreadDepth + num2);
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbInnerRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex),
					m_ptStart = new XYZ(num, 0.0, 0.0)
				});
				num = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingLength + (double)this.TwoRunTreadCount * this.TreadDepth + this.MiddleLandingWidth - num2);
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbInnerRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex),
					m_ptStart = new XYZ(num, 0.0, 0.0)
				});
				num = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingLength + (double)this.TwoRunTreadCount * this.TreadDepth * 2.0 + this.MiddleLandingWidth + this.SideLandingLength - this.SideStairsWidth);
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbInnerRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex),
					m_ptStart = new XYZ(num, 0.0, 0.0)
				});
			}
			if (this.chkOutRailing.Checked)
			{
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbOutRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbOutRailingType.SelectedIndex),
					m_ptStart = XYZ.Zero
				});
				double num3 = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingLength * 2.0 + (double)this.TwoRunTreadCount * this.TreadDepth * 2.0 + this.MiddleLandingWidth);
				list.Add(new BaseRaillingData
				{
					RailingHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbOutRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbOutRailingType.SelectedIndex),
					m_ptStart = new XYZ(num3, 0.0, 0.0)
				});
			}
			return list;
		}

		public List<BaseSupportData> GetSupportData()
		{
			List<BaseSupportData> list = new List<BaseSupportData>();
			if (this.chkOutSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_OutSide
				});
			}
			if (this.chkMiddleSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Mid,
					nSurportNum = 3
				});
			}
			if (this.chkInsideSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Inside
				});
			}
			return list;
		}

		public AngleLandingData GetMiddleLandingData()
		{
			AngleLandingData angleLandingData = new AngleLandingData();
			angleLandingData.Width = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.MiddleLandingWidth);
			if (!this.m_bCenterStart && 1E-09 >= this.MiddleLandingLength - this.TwoRunStairsWidth)
			{
				angleLandingData.Length = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.MiddleLandingLength + 0.01);
			}
			else
			{
				angleLandingData.Length = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.MiddleLandingLength);
			}
			int num;
			if (this.m_bCenterStart)
			{
				num = this.MiddleTreadCount + 1;
			}
			else
			{
				num = this.SideTreadCount + this.TwoRunTreadCount + 2;
			}
			angleLandingData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)num * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			angleLandingData.LandingThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.LandingThickness);
			return angleLandingData;
		}

		public AngleLandingData GetSideLandingData()
		{
			AngleLandingData angleLandingData = new AngleLandingData();
			angleLandingData.Width = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingWidth);
			angleLandingData.Length = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.SideLandingLength);
			int num;
			if (this.m_bCenterStart)
			{
				num = this.MiddleTreadCount + this.TwoRunTreadCount + 2;
			}
			else
			{
				num = this.SideTreadCount + 1;
			}
			angleLandingData.BottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dBottomElevation) + (double)num * StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			angleLandingData.LandingThickness = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet((double)this.LandingThickness);
			return angleLandingData;
		}

		public BaseBeamData GetBeamData()
		{
			return new BaseBeamData
			{
				BeamHeight = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.BeamHeight),
				BeamWidth = StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.BeamWidth)
			};
		}

        public StairsModuleAndEdit.StairsModel.DataInfos.FloorType GetFloorType()
		{
			if (this.rbFirstFloor.Checked)
			{
                return StairsModuleAndEdit.StairsModel.DataInfos.FloorType.FT_Bottom;
			}
			if (this.rbMiddleFloor.Checked)
			{
                return StairsModuleAndEdit.StairsModel.DataInfos.FloorType.FT_Mid;
			}
            return StairsModuleAndEdit.StairsModel.DataInfos.FloorType.FT_Top;
		}

		public List<string> GetLandWidth()
		{
			return new List<string>
			{
				this.MiddleLandingWidth.ToString("f2"),
				this.SideLandingWidth.ToString("f2")
			};
		}

		public bool GetUpstairsLoc()
		{
			return this.m_bCenterStart;
		}

		public bool GetNoteInfo()
		{
			return this.chkNoteInfo.Checked;
		}

		public bool GetTBMirror()
		{
			return this.chkTBMirror.Checked;
		}

		public bool GetLRMirror()
		{
			return this.chkLRMirror.Checked;
		}

		public int GetInsertPointIndex()
		{
			return this.m_BasePointIndex;
		}

		public bool GetBottomBeam()
		{
			return this.chkBottomBeam.Checked;
		}

		public bool GetMiddleBeam()
		{
			return this.chkMiddleBeam.Checked;
		}

		public bool GetTopBeam()
		{
			return this.chkTopBeam.Checked;
		}

		public double GetBottomElevation()
		{
			return this.m_BottomLevel.Elevation;
		}

		public double GetLevelValue()
		{
			return StairsModuleAndEdit.StairsModel.CommonUnit.Common.MMToFeet(this.m_dLevelValue);
		}

		public double GetTopOffset()
		{
			return this.TopOffset;
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (m.WParam.ToInt32() != 1)
				{
					return;
				}
				List<CurveInfo> curves = new List<CurveInfo>();
				List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
				try
				{
					this.GetProfileCurves(ref curves, ref textNotes);
					this.m_MainPreviewer.Curves = curves;
					this.m_MainPreviewer.TextNotes = textNotes;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			base.DefWndProc(ref m);
		}

		private void GetProfileCurves(ref List<CurveInfo> curvesInfoList, ref List<TextNoteInfo> textNoteInfoList)
		{
			DoubleBranchThreeRunStairs doubleBranchThreeRunStairs = new DoubleBranchThreeRunStairs();
			doubleBranchThreeRunStairs.m_LeftRunData = this.GetSideStairsData();
			doubleBranchThreeRunStairs.m_MidRunData = this.GetMiddleStairsData();
			doubleBranchThreeRunStairs.m_RightRunData = this.GetSideStairsData();
			doubleBranchThreeRunStairs.m_TwoRunLeftData = this.GetTwoRunStairsData();
			doubleBranchThreeRunStairs.m_TwoRunRightData = this.GetTwoRunStairsData();
			doubleBranchThreeRunStairs.m_SideLandData = this.GetSideLandingData();
			doubleBranchThreeRunStairs.m_MiddleLandData = this.GetMiddleLandingData();
			doubleBranchThreeRunStairs.m_BeamData = this.GetBeamData();
			doubleBranchThreeRunStairs.m_FloorType = this.GetFloorType();
			doubleBranchThreeRunStairs.m_bIsCenterUp = this.m_bCenterStart;
			this.m_StairsDrawingKit.DoubleBranchThreeRunStairsProfileCurves(ref doubleBranchThreeRunStairs, this.chkNoteInfo.Checked, this.m_BasePointIndex, this.chkLRMirror.Checked, this.chkTBMirror.Checked, this.RotateAngle, this.chkBottomBeam.Checked, this.chkMiddleBeam.Checked, this.chkTopBeam.Checked);
			foreach (SingleRunCurveInfo singleRunCurveInfo in doubleBranchThreeRunStairs.m_listRunCurve)
			{
				curvesInfoList.AddRange(singleRunCurveInfo.RunBoundaryCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunRiserCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunPathCurvesInfoList);
			}
			foreach (LandingCurveInfo landingCurveInfo in doubleBranchThreeRunStairs.m_listLandCurve)
			{
				curvesInfoList.AddRange(landingCurveInfo.m_arCurveInfo);
			}
			curvesInfoList.AddRange(doubleBranchThreeRunStairs.m_listOtherCurve);
			textNoteInfoList = doubleBranchThreeRunStairs.m_listText;
		}

		private void ReadData()
		{
			string userDataLocation = Product.UserDataLocation;
			string path = userDataLocation + "LinearDoubleBranceThreeRunStairsForm.dat";
			if (!File.Exists(path))
			{
				this.m_Calculating = true;
				this.comboUsingRange.Text = "商场";
				this.hyTbTopOffset.Text = "0.00";
				this.hyTbBottomOffset.Text = "0.00";
				this.hyTbSideStairsWidth.Text = "1200.00";
				this.hyTbMiddleStairsWidth.Text = "2400.00";
				this.hyTbTwoRunStairsWidth.Text = "1200.00";
				this.nudTreadCount.Value = 27m;
				this.nudSideTreadCount.Value = 9m;
				this.nudMidTreadCount.Value = 9m;
				this.nudTwoRunTreadCount.Value = 9m;
				this.hyTbTreadHeight.Text = "150.00";
				this.hyTbTreadDepth.Text = "280.00";
				this.tbRunThickness.Text = "120";
				this.tbLandThickness.Text = "120";
				this.tbRiserThickness.Text = "30";
				this.tbTreadThickness.Text = "30";
				this.chkInnerRailing.Checked = true;
				this.chkOutRailing.Checked = true;
				this.chkOutSupport.Checked = false;
				this.chkMiddleSupport.Checked = false;
				this.chkInsideSupport.Checked = false;
				this.chkBottomBeam.Checked = true;
				this.chkMiddleBeam.Checked = true;
				this.chkTopBeam.Checked = true;
				this.hyTbBeamWidth.Text = "200.00";
				this.hyTbBeamHeight.Text = "400.00";
				this.hyTbMidLandingLength.Text = "1200.00";
				this.hyTbMidLandingWidth.Text = "2700.00";
				this.hyTbSideLandingLength.Text = "1200.00";
				this.hyTbSideLandingWidth.Text = "1400.00";
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				this.rbTopFloor.Checked = false;
				this.rbMiddleLoc.Checked = true;
				this.rbBothSides.Checked = false;
				this.hyTbRotateAngle.Text = "0.00";
				this.chkTBMirror.Checked = false;
				this.chkLRMirror.Checked = false;
				this.chkNoteInfo.Checked = true;
				this.m_Calculating = false;
				return;
			}
			this.m_Calculating = true;
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			int index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.comboUsingRange, index);
			this.hyTbTopOffset.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbBottomOffset.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbSideStairsWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbMiddleStairsWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTwoRunStairsWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.nudTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudSideTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudMidTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudTwoRunTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.hyTbTreadHeight.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTreadDepth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.tbRunThickness.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbLandThickness.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbRiserThickness.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.tbTreadThickness.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.chkInnerRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkOutRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbInnerRailingType, index);
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbOutRailingType, index);
			this.chkOutSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkMiddleSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkInsideSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbSupport, index);
			this.chkBottomBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkMiddleBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkTopBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.hyTbBeamWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbBeamHeight.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbMidLandingLength.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbMidLandingWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbSideLandingLength.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbSideLandingWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			int num = Convert.ToInt32(streamReader.ReadLine());
			if (num == 0)
			{
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = false;
			}
			else if (1 == num)
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				this.rbTopFloor.Checked = false;
			}
			else
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = true;
			}
			if (Convert.ToInt32(streamReader.ReadLine()) == 0)
			{
				this.rbMiddleLoc.Checked = true;
				this.rbBothSides.Checked = false;
			}
			else
			{
				this.rbMiddleLoc.Checked = false;
				this.rbBothSides.Checked = true;
			}
			this.hyTbRotateAngle.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.m_BasePointIndex = Convert.ToInt32(streamReader.ReadLine());
			this.chkTBMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkLRMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkNoteInfo.Checked = Convert.ToBoolean(streamReader.ReadLine());
			streamReader.Close();
			fileStream.Close();
			this.m_Calculating = false;
		}

		public void SaveData()
		{
			string userDataLocation = Product.UserDataLocation;
			string path = userDataLocation + "LinearDoubleBranceThreeRunStairsForm.dat";
			FileStream fileStream = new FileStream(path, FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(this.comboUsingRange.SelectedIndex);
			streamWriter.WriteLine(this.hyTbTopOffset.Text);
			streamWriter.WriteLine(this.hyTbBottomOffset.Text);
			streamWriter.WriteLine(this.hyTbSideStairsWidth.Text);
			streamWriter.WriteLine(this.hyTbMiddleStairsWidth.Text);
			streamWriter.WriteLine(this.hyTbTwoRunStairsWidth.Text);
			streamWriter.WriteLine(this.nudTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudSideTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudMidTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudTwoRunTreadCount.Value.ToString());
			streamWriter.WriteLine(this.hyTbTreadHeight.Text);
			streamWriter.WriteLine(this.hyTbTreadDepth.Text);
			streamWriter.WriteLine(this.tbRunThickness.Text);
			streamWriter.WriteLine(this.tbLandThickness.Text);
			streamWriter.WriteLine(this.tbRiserThickness.Text);
			streamWriter.WriteLine(this.tbTreadThickness.Text);
			streamWriter.WriteLine(this.chkInnerRailing.Checked);
			streamWriter.WriteLine(this.chkOutRailing.Checked);
			streamWriter.WriteLine(this.cmbInnerRailingType.SelectedIndex);
			streamWriter.WriteLine(this.cmbOutRailingType.SelectedIndex);
			streamWriter.WriteLine(this.chkOutSupport.Checked);
			streamWriter.WriteLine(this.chkMiddleSupport.Checked);
			streamWriter.WriteLine(this.chkInsideSupport.Checked);
			streamWriter.WriteLine(this.cmbSupport.SelectedIndex);
			streamWriter.WriteLine(this.chkBottomBeam.Checked);
			streamWriter.WriteLine(this.chkMiddleBeam.Checked);
			streamWriter.WriteLine(this.chkTopBeam.Checked);
			streamWriter.WriteLine(this.hyTbBeamWidth.Text);
			streamWriter.WriteLine(this.hyTbBeamHeight.Text);
			streamWriter.WriteLine(this.hyTbMidLandingLength.Text);
			streamWriter.WriteLine(this.hyTbMidLandingWidth.Text);
			streamWriter.WriteLine(this.hyTbSideLandingLength.Text);
			streamWriter.WriteLine(this.hyTbSideLandingWidth.Text);
			if (this.rbFirstFloor.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rbMiddleFloor.Checked)
			{
				streamWriter.WriteLine(1);
			}
			else
			{
				streamWriter.WriteLine(2);
			}
			if (this.rbMiddleLoc.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else
			{
				streamWriter.WriteLine(1);
			}
			streamWriter.WriteLine(this.hyTbRotateAngle.Text);
			streamWriter.WriteLine(this.m_BasePointIndex);
			streamWriter.WriteLine(this.chkTBMirror.Checked);
			streamWriter.WriteLine(this.chkLRMirror.Checked);
			streamWriter.WriteLine(this.chkNoteInfo.Checked);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private void LinearDoubleBranceThreeRunStairsForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.InitializeComboBox(this.comboUsingRange, this.m_ComponentTypeManager.GetUsingRangeList());
			this.InitializeComboBox(this.cmbInnerRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbOutRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbSupport, this.m_ComponentTypeManager.GetSupportTypeNameList());
			List<string> list = new List<string>();
			foreach (Element element in this.m_listAllLevels)
			{
				if (!list.Contains(element.Name))
				{
					list.Add(element.Name);
				}
			}
			this.InitializeComboBox(this.cmbTopLevel, list);
			this.InitializeComboBox(this.cmbBottomLevel, list);
			this.ReadData();
			this.UpdateRailingData();
			this.UpdateSupportData();
			this.UpdateBeamData();
			this.UpdateStairsData();
			this.m_BottomLevel = this.m_Revit.Application.ActiveUIDocument.ActiveView.GenLevel;
			for (int i = 0; i < this.m_listAllLevels.Count; i++)
			{
				if (this.m_BottomLevel.Id == this.m_listAllLevels.ElementAt(i).Id)
				{
					if (this.m_listAllLevels.Count - 1 == i)
					{
						this.m_TopLevel = this.m_BottomLevel;
						this.cmbTopLevel.SelectedIndex = i;
						this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_BottomLevel.Elevation - this.m_listAllLevels.ElementAt(i - 1).Elevation);
						this.TopOffset = this.m_dLevelValue;
					}
					else
					{
						this.m_TopLevel = this.m_listAllLevels.ElementAt(i + 1);
						this.cmbTopLevel.SelectedIndex = i + 1;
						this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
						this.TopOffset = 0.0;
					}
					this.cmbBottomLevel.SelectedIndex = i;
					break;
				}
			}
			this.BottomOffset = 0.0;
		}

		private void LinearDoubleBranceThreeRunStairsForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (DialogResult.Cancel == base.DialogResult)
			{
				return;
			}
			string text = "";
			if (!this.ValidatingParameters(ref text))
			{
				MessageBox.Show(text, "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
			this.SaveData();
		}

        private void InitializeComboBox(System.Windows.Forms.ComboBox control, List<string> typeNameList)
		{
			control.Items.Clear();
			foreach (string item in typeNameList)
			{
				control.Items.Add(item);
			}
			if (control.Items.Count > 0)
			{
				control.SelectedIndex = 0;
			}
		}

		private void SetComboBoxSelectedIndex(System.Windows.Forms.ComboBox control, int index)
		{
			if (index < 0 || index >= control.Items.Count)
			{
				return;
			}
			control.SelectedIndex = index;
		}

		private bool ValidatingParameters(ref string message)
		{
			if (this.chkInnerRailing.Checked || this.chkOutRailing.Checked)
			{
				if (this.cmbInnerRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
				if (this.cmbOutRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
			}
			if ((this.chkOutSupport.Checked || this.chkMiddleSupport.Checked || this.chkInsideSupport.Checked) && this.cmbSupport.Items.Count == 0)
			{
				message = "支持类型为空";
				return false;
			}
			return true;
		}

		private bool ValidatingDataParam(ref string message)
		{
			List<ValidatingData> list = new List<ValidatingData>();
			ValidatingData item = new ValidatingData
			{
				Type = DataType.DT_RunWidth,
				Name = "边梯段宽",
				Value = this.SideStairsWidth
			};
			list.Add(item);
			item.Type = DataType.DT_RunWidth;
			item.Name = "中梯段宽";
			item.Value = this.MiddleStairsWidth;
			list.Add(item);
			item.Type = DataType.DT_RunWidth;
			item.Name = "二跑段宽";
			item.Value = this.TwoRunStairsWidth;
			list.Add(item);
			item.Type = DataType.DT_TreadHeight;
			item.Name = "踏步高度";
			item.Value = this.TreadHeight;
			list.Add(item);
			item.Type = DataType.DT_TreadDepth;
			item.Name = "踏步宽度";
			item.Value = this.TreadDepth;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "边梯步数";
			item.Count = this.SideTreadCount;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "中梯步数";
			item.Count = this.MiddleTreadCount;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "二跑步数";
			item.Count = this.TwoRunTreadCount;
			list.Add(item);
			item.Type = DataType.DT_LandWidth;
			item.Name = "中平台宽";
			item.Value = this.MiddleLandingWidth;
			list.Add(item);
			item.Type = DataType.DT_LandWidth;
			item.Name = "中平台长";
			item.Value = this.MiddleLandingLength;
			list.Add(item);
			item.Type = DataType.DT_LandWidth;
			item.Name = "边平台宽";
			item.Value = this.SideLandingWidth;
			list.Add(item);
			item.Type = DataType.DT_LandWidth;
			item.Name = "边平台长";
			item.Value = this.SideLandingLength;
			list.Add(item);
			double dRunWdith = (this.SideStairsWidth > this.MiddleStairsWidth) ? this.SideStairsWidth : this.MiddleStairsWidth;
			message = FormParamManager.GetValidatingData(list, this.UsingRange, dRunWdith);
			return message == null;
		}

		private void ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType changeType)
		{
			if (this.m_Calculating)
			{
				return;
			}
			this.m_Calculating = true;
			try
			{
				double stairsHeight = FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset);
				int num = FormParamManager.GetStairsTreadCount(stairsHeight, this.TreadHeight) - 3;
				switch (changeType)
				{
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight:
					if (num % 3 == 0)
					{
						this.SideTreadCount = num / 3;
						this.MiddleTreadCount = this.SideTreadCount;
						this.TwoRunTreadCount = this.SideTreadCount;
					}
					else
					{
						this.SideTreadCount = num / 3;
						this.MiddleTreadCount = this.SideTreadCount;
						this.TwoRunTreadCount = num - this.SideTreadCount * 2;
					}
					this.TreadCount = this.SideTreadCount + this.MiddleTreadCount + this.TwoRunTreadCount;
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCount:
					if (this.TreadCount % 3 == 0)
					{
						this.SideTreadCount = this.TreadCount / 3;
						this.MiddleTreadCount = this.SideTreadCount;
						this.TwoRunTreadCount = this.SideTreadCount;
					}
					else
					{
						this.SideTreadCount = this.TreadCount / 3;
						this.MiddleTreadCount = this.SideTreadCount;
						this.TwoRunTreadCount = this.TreadCount - this.SideTreadCount * 2;
					}
					this.TreadHeight = stairsHeight / (double)(this.TreadCount + 3);
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCount:
					this.MiddleTreadCount = this.TreadCount - this.SideTreadCount - this.TwoRunTreadCount;
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCount:
					this.SideTreadCount = this.TreadCount - this.MiddleTreadCount - this.TwoRunTreadCount;
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCount:
					if ((this.TreadCount - this.TwoRunTreadCount) % 2 == 0)
					{
						this.SideTreadCount = (this.TreadCount - this.TwoRunTreadCount) / 2;
						this.MiddleTreadCount = this.SideTreadCount;
					}
					else
					{
						this.SideTreadCount = (this.TreadCount - this.TwoRunTreadCount) / 2;
						this.MiddleTreadCount = this.SideTreadCount + 1;
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCountAdd:
					this.TreadCountChanged(true);
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCountAdd:
					if (3 == this.MiddleTreadCount)
					{
						this.SideTreadCount--;
					}
					else
					{
						this.SideTreadCountChanged(true);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCountAdd:
					if (3 == this.SideTreadCount)
					{
						this.MiddleTreadCount--;
					}
					else
					{
						this.MiddleTreadCountChanged(true);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCountAdd:
					if (3 == this.MiddleTreadCount)
					{
						this.TwoRunTreadCount--;
					}
					else
					{
						this.TwoRunTreadCountChanged(true);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCountSub:
					if (9 > this.TreadCount)
					{
						this.TreadCount++;
					}
					else
					{
						this.TreadCountChanged(false);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCountSub:
					if (3 > this.SideTreadCount)
					{
						this.SideTreadCount++;
					}
					else
					{
						this.SideTreadCountChanged(false);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCountSub:
					if (3 > this.MiddleTreadCount)
					{
						this.MiddleTreadCount++;
					}
					else
					{
						this.MiddleTreadCountChanged(false);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCountSub:
					if (3 > this.TwoRunTreadCount)
					{
						this.TwoRunTreadCount++;
					}
					else
					{
						this.TwoRunTreadCountChanged(false);
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideStairsWidth:
					if (1E-09 < this.SideStairsWidth - this.SideLandingLength)
					{
						this.SideLandingLength = this.SideStairsWidth;
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleStairsWidth:
					if (1E-09 < this.MiddleStairsWidth - this.MiddleLandingWidth)
					{
						this.MiddleLandingWidth = this.MiddleStairsWidth;
					}
					break;
				case LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunStairsWidth:
					if (1E-09 < this.TwoRunStairsWidth - this.SideLandingWidth)
					{
						this.SideLandingWidth = this.TwoRunStairsWidth;
					}
					if (1E-09 < this.TwoRunStairsWidth - this.MiddleLandingLength)
					{
						this.MiddleLandingLength = this.TwoRunStairsWidth;
					}
					break;
				}
				this.m_Calculating = false;
			}
			catch (Exception)
			{
				this.m_Calculating = false;
			}
		}

		private void CalcCmpTreadCount()
		{
			try
			{
				double stairsHeight = FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset);
				int num = FormParamManager.GetStairsTreadCount(stairsHeight, this.TreadHeight) - 3;
				if (num % 3 == 0)
				{
					this.m_nSideRunCmpTreadCnt = num / 3;
					this.m_nMidRunCmpTreadCnt = this.m_nSideRunCmpTreadCnt;
					this.m_nTwoRunCmpTreadCnt = this.m_nSideRunCmpTreadCnt;
				}
				else
				{
					this.m_nSideRunCmpTreadCnt = num / 3;
					this.m_nMidRunCmpTreadCnt = this.m_nSideRunCmpTreadCnt;
					this.m_nTwoRunCmpTreadCnt = num - this.m_nSideRunCmpTreadCnt * 2;
				}
			}
			catch
			{
				this.m_nSideRunCmpTreadCnt = 2;
				this.m_nMidRunCmpTreadCnt = 2;
				this.m_nTwoRunCmpTreadCnt = 2;
			}
		}

		private bool IsNotValidRunMinTread()
		{
			bool result = false;
			this.CalcCmpTreadCount();
			if (this.m_nSideRunCmpTreadCnt < FormParamManager.m_nRunMinTreadCount || this.m_nMidRunCmpTreadCnt < FormParamManager.m_nRunMinTreadCount || this.m_nTwoRunCmpTreadCnt < FormParamManager.m_nRunMinTreadCount)
			{
				result = true;
			}
			return result;
		}

		private LinearDoubleBranceThreeRunStairsForm.ValveChangeType isAddNumericUpDown(NumericUpDown ctrl)
		{
			string text = ctrl.Text;
			int num = Convert.ToInt32(text);
			int num2 = Convert.ToInt32(ctrl.Value.ToString());
			if (num2 == num)
			{
				return LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_None;
			}
			if (num2 == num + 1)
			{
				return LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_AddOne;
			}
			if (num2 + 1 == num)
			{
				return LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_SubtractOne;
			}
			return LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_ValveChanged;
		}

		private void TreadCountChanged(bool isAdd)
		{
			if (this.TreadCount % 3 == 0)
			{
				this.SideTreadCount = this.TreadCount / 3;
				this.MiddleTreadCount = this.SideTreadCount;
				this.TwoRunTreadCount = this.SideTreadCount;
			}
			else
			{
				this.SideTreadCount = this.TreadCount / 3;
				this.MiddleTreadCount = this.SideTreadCount;
				this.TwoRunTreadCount = this.TreadCount - this.SideTreadCount * 2;
			}
			this.TreadHeight = FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset) / (double)(this.TreadCount + 3);
		}

		private void SideTreadCountChanged(bool isAdd)
		{
			if (isAdd)
			{
				this.nudMidTreadCount.Value = --this.nudMidTreadCount.Value;
				return;
			}
			this.nudMidTreadCount.Value = ++this.nudMidTreadCount.Value;
		}

		private void MiddleTreadCountChanged(bool isAdd)
		{
			if (isAdd)
			{
				this.nudSideTreadCount.Value = --this.nudSideTreadCount.Value;
				return;
			}
			this.nudSideTreadCount.Value = ++this.nudSideTreadCount.Value;
		}

		private void TwoRunTreadCountChanged(bool isAdd)
		{
			if ((this.TreadCount - this.TwoRunTreadCount) % 2 == 0)
			{
				this.SideTreadCount = (this.TreadCount - this.TwoRunTreadCount) / 2;
				this.MiddleTreadCount = this.SideTreadCount;
				return;
			}
			this.SideTreadCount = (this.TreadCount - this.TwoRunTreadCount) / 2;
			this.MiddleTreadCount = this.SideTreadCount + 1;
		}

		private void UpdateRailingData()
		{
			if (!this.chkInnerRailing.Checked)
			{
				this.cmbInnerRailingType.Enabled = false;
			}
			else
			{
				this.cmbInnerRailingType.Enabled = true;
			}
			if (!this.chkOutRailing.Checked)
			{
				this.cmbOutRailingType.Enabled = false;
				return;
			}
			this.cmbOutRailingType.Enabled = true;
		}

		private void UpdateSupportData()
		{
			if (!this.chkOutSupport.Checked && !this.chkInsideSupport.Checked)
			{
				this.cmbSupport.Enabled = false;
				return;
			}
			this.cmbSupport.Enabled = true;
		}

		private void UpdateBeamData()
		{
			if (!this.chkBottomBeam.Checked && !this.chkMiddleBeam.Checked && !this.chkTopBeam.Checked)
			{
				this.hyTbBeamWidth.Enabled = false;
				this.hyTbBeamHeight.Enabled = false;
				return;
			}
			this.hyTbBeamWidth.Enabled = true;
			this.hyTbBeamHeight.Enabled = true;
		}

		private void UpdateStairsData()
		{
			this.m_listStairsData.Clear();
			this.m_listStairsData.Add(this.SideStairsWidth);
			this.m_listStairsData.Add(this.MiddleStairsWidth);
			this.m_listStairsData.Add(this.TwoRunStairsWidth);
			this.m_listStairsData.Add(this.TreadHeight);
			this.m_listStairsData.Add(this.TreadDepth);
			this.m_listStairsData.Add(this.BeamWidth);
			this.m_listStairsData.Add(this.BeamHeight);
			this.m_listStairsData.Add(this.MiddleLandingLength);
			this.m_listStairsData.Add(this.MiddleLandingWidth);
			this.m_listStairsData.Add(this.SideLandingLength);
			this.m_listStairsData.Add(this.SideLandingWidth);
			this.m_listStairsData.Add(this.RotateAngle);
		}

		private void chkInnerRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMiddleSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkInnerSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkBottomBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMiddleBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkTopBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkTBMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkLRMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkNoteInfo_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbMiddlePos_CheckedChanged(object sender, EventArgs e)
		{
			this.m_bCenterStart = true;
			this.m_MainPreviewer.Refresh();
		}

		private void rbBothSides_CheckedChanged(object sender, EventArgs e)
		{
			this.m_bCenterStart = false;
			this.m_MainPreviewer.Refresh();
		}

		private void rbFirstFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbMiddleFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbTopFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTopOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBottomOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbSideStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideStairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbMiddleStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleStairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTwoRunStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunStairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadHeight_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadDepth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamHeight_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRotateAngle_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbMidLandingLength_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbMidLandingWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbSideLandingLength_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbSideLandingWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void cmbTopLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex && this.cmbTopLevel.SelectedIndex == 0)
			{
				return;
			}
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void cmbBottomLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void hyTbTopOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTopOffset.Text)
			{
				return;
			}
			this.hyTbTopOffset.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbTopOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbTopOffset.Focus();
				return;
			}
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTopOffset.Text, ValidatingType.None, ref num))
			{
				MessageBox.Show("楼梯顶高参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				MessageBox.Show(FormParamManager.m_strRunMinTreadChkTip, "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbTopOffset.Focus();
			}
		}

		private void hyTbBottomOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBottomOffset.Text)
			{
				return;
			}
			this.hyTbBottomOffset.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbBottomOffset.Focus();
				return;
			}
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBottomOffset.Text, ValidatingType.None, ref num))
			{
				MessageBox.Show("起始高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				FormParamManager.MessageBoxWarning(FormParamManager.m_strRunMinTreadChkTip);
				this.hyTbBottomOffset.Focus();
			}
		}

		private void hyTbSideStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbSideStairsWidth.Text)
			{
				return;
			}
			this.hyTbSideStairsWidth.Text = Convert.ToDouble(this.hyTbSideStairsWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbSideStairsWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯段净宽参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.SideStairsWidth = this.m_listStairsData.ElementAt(0);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbMiddleStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbMiddleStairsWidth.Text)
			{
				return;
			}
			this.hyTbMiddleStairsWidth.Text = Convert.ToDouble(this.hyTbMiddleStairsWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbMiddleStairsWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯段净宽参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.MiddleStairsWidth = this.m_listStairsData.ElementAt(1);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTwoRunStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTwoRunStairsWidth.Text)
			{
				return;
			}
			this.hyTbTwoRunStairsWidth.Text = Convert.ToDouble(this.hyTbTwoRunStairsWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTwoRunStairsWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯段净宽参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TwoRunStairsWidth = this.m_listStairsData.ElementAt(2);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTreadHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadHeight.Text)
			{
				return;
			}
			this.hyTbTreadHeight.Text = Convert.ToDouble(this.hyTbTreadHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadHeight = this.m_listStairsData.ElementAt(3);
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				FormParamManager.MessageBoxWarning(FormParamManager.m_strRunMinTreadChkTip);
				e.Cancel = true;
				this.TreadHeight = this.m_listStairsData.ElementAt(3);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTreadDepth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadDepth.Text)
			{
				return;
			}
			this.hyTbTreadDepth.Text = Convert.ToDouble(this.hyTbTreadDepth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadDepth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadDepth = this.m_listStairsData.ElementAt(4);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbBeamWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamWidth.Text)
			{
				return;
			}
			this.hyTbBeamWidth.Text = Convert.ToDouble(this.hyTbBeamWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamWidth = this.m_listStairsData.ElementAt(5);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbBeamHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamHeight.Text)
			{
				return;
			}
			this.hyTbBeamHeight.Text = Convert.ToDouble(this.hyTbBeamHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamHeight = this.m_listStairsData.ElementAt(6);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbMidLandingLength_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbMidLandingLength.Text)
			{
				return;
			}
			this.hyTbMidLandingLength.Text = Convert.ToDouble(this.hyTbMidLandingLength.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbMidLandingLength.Text, ValidatingType.GreaterThanZero, ref num) || this.MiddleLandingLength < this.TwoRunStairsWidth)
			{
				MessageBox.Show("中平台长度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.MiddleLandingLength = this.m_listStairsData.ElementAt(7);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbMidLandingWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbMidLandingWidth.Text)
			{
				return;
			}
			this.hyTbMidLandingWidth.Text = Convert.ToDouble(this.hyTbMidLandingWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbMidLandingWidth.Text, ValidatingType.GreaterThanZero, ref num) || this.MiddleLandingWidth < this.MiddleStairsWidth)
			{
				MessageBox.Show("中平台宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.MiddleLandingWidth = this.m_listStairsData.ElementAt(8);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbSideLandingLength_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbSideLandingLength.Text)
			{
				return;
			}
			this.hyTbSideLandingLength.Text = Convert.ToDouble(this.hyTbSideLandingLength.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbSideLandingLength.Text, ValidatingType.GreaterThanZero, ref num) || this.SideLandingLength < this.SideStairsWidth)
			{
				MessageBox.Show("边平台长度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.SideLandingLength = this.m_listStairsData.ElementAt(9);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbSideLandingWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbSideLandingWidth.Text)
			{
				return;
			}
			this.hyTbSideLandingWidth.Text = Convert.ToDouble(this.hyTbSideLandingWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbMidLandingWidth.Text, ValidatingType.GreaterThanZero, ref num) || this.SideLandingWidth < this.TwoRunStairsWidth)
			{
				MessageBox.Show("边平台宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.SideLandingWidth = this.m_listStairsData.ElementAt(10);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbRotateAngle_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbRotateAngle.Text)
			{
				return;
			}
			this.hyTbRotateAngle.Text = StairsModuleAndEdit.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbRotateAngle.Text, ValidatingType.Minus2PITo2PI, ref num))
			{
				MessageBox.Show("旋转角度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.RotateAngle = this.m_listStairsData.ElementAt(11);
				return;
			}
			this.UpdateStairsData();
		}

		private void cmbTopLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
		}

		private void cmbBottomLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
		}

		private void btnSideStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = LinearDoubleBranceThreeRunStairsForm.MeasureType.MT_SideWidth;
			this.hyTbSideStairsWidth.Focus();
		}

		private void btnMiddleStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = LinearDoubleBranceThreeRunStairsForm.MeasureType.MT_MiddleWidth;
			this.hyTbMiddleStairsWidth.Focus();
		}

		private void btnTwoRunStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = LinearDoubleBranceThreeRunStairsForm.MeasureType.MT_TwoRunWidth;
			this.hyTbTwoRunStairsWidth.Focus();
		}

		private void btnRotateAngle_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = LinearDoubleBranceThreeRunStairsForm.MeasureType.MT_Angle;
		}

		private void btnChangeInsertPoint_Click(object sender, EventArgs e)
		{
			int num = this.m_BasePointIndex + 1;
			this.m_BasePointIndex = num % 6;
			this.m_MainPreviewer.Refresh();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (StairsFormManager.IsInvalidFormInput(this))
			{
				return;
			}
			this.m_MeasureType = LinearDoubleBranceThreeRunStairsForm.MeasureType.MT_None;
			string text = "";
			if (!this.ValidatingDataParam(ref text))
			{
				DialogResult dialogResult = MessageBox.Show(text, "盈建科提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
				if (DialogResult.Cancel == dialogResult)
				{
					return;
				}
				if (DialogResult.OK == dialogResult)
				{
					base.DialogResult = DialogResult.OK;
					base.Close();
				}
			}
			base.DialogResult = DialogResult.OK;
		}

		private void nudTreadCount_ValueChanged(object sender, EventArgs e)
		{
			LinearDoubleBranceThreeRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudTreadCount);
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCountAdd);
			}
			else if (LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudSideTreadCount_ValueChanged(object sender, EventArgs e)
		{
			LinearDoubleBranceThreeRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudSideTreadCount);
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCountAdd);
			}
			else if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudMidTreadCount_ValueChanged(object sender, EventArgs e)
		{
			LinearDoubleBranceThreeRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudMidTreadCount);
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCountAdd);
			}
			else if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudTwoRunTreadCount_ValueChanged(object sender, EventArgs e)
		{
			LinearDoubleBranceThreeRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudTwoRunTreadCount);
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCountAdd);
			}
			else if (valveChangeType == LinearDoubleBranceThreeRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudTreadCount_KeyUp(object sender, KeyEventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadCount);
			this.m_MainPreviewer.Refresh();
		}

		private void nudSideTreadCount_KeyUp(object sender, KeyEventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_SideTreadCount);
			this.m_MainPreviewer.Refresh();
		}

		private void nudMidTreadCount_KeyUp(object sender, KeyEventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_MiddleTreadCount);
			this.m_MainPreviewer.Refresh();
		}

		private void nudTwoRunTreadCount_KeyUp(object sender, KeyEventArgs e)
		{
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TwoRunTreadCount);
			this.m_MainPreviewer.Refresh();
		}

		private void cmbTopLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_TopLevel = this.m_listAllLevels.ElementAt(selectedIndex);
			this.hyTbTopOffset.Text = "0.00";
			if (-1 == selectedIndex2)
			{
				return;
			}
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void cmbBottomLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_BottomLevel = this.m_listAllLevels.ElementAt(selectedIndex2);
			this.hyTbBottomOffset.Text = "0.00";
			this.m_dBottomElevation = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_BottomLevel.Elevation);
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = StairsModuleAndEdit.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(LinearDoubleBranceThreeRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		public const double _epsDouble = 1E-09;

		private const int m_nRiserSubTread = 3;

		private ExternalCommandData m_Revit;

		private Previewer m_MainPreviewer;

		private DoubleBranceThreeRunStairsKit m_StairsDrawingKit;

		private ComponentTypeManager m_ComponentTypeManager;

		private List<Level> m_listAllLevels;

		private LinearDoubleBranceThreeRunStairsForm.MeasureType m_MeasureType;

		private XYZ m_BasePoint;

		private int m_BasePointIndex;

		private bool m_Calculating;

		private bool m_bCenterStart = true;

		private double m_dBottomElevation;

		private double m_dLevelValue;

		private Level m_TopLevel;

		private Level m_BottomLevel;

		private List<double> m_listStairsData;

		private double m_dStairsHeight;

		private int m_nSideRunCmpTreadCnt = 3;

		private int m_nMidRunCmpTreadCnt = 3;

		private int m_nTwoRunCmpTreadCnt = 3;

		public enum MeasureType
		{
			MT_None,
			MT_SideWidth,
			MT_MiddleWidth,
			MT_TwoRunWidth,
			MT_Angle
		}

		public enum ValveChangeType
		{
			VCT_None,
			VCT_AddOne,
			VCT_SubtractOne,
			VCT_ValveChanged
		}

		private enum ParametersChangeType
		{
			PCT_TreadHeight,
			PCT_TreadDepth,
			PCT_TreadCount,
			PCT_SideTreadCount,
			PCT_MiddleTreadCount,
			PCT_TwoRunTreadCount,
			PCT_TreadCountAdd,
			PCT_SideTreadCountAdd,
			PCT_MiddleTreadCountAdd,
			PCT_TwoRunTreadCountAdd,
			PCT_TreadCountSub,
			PCT_SideTreadCountSub,
			PCT_MiddleTreadCountSub,
			PCT_TwoRunTreadCountSub,
			PCT_SideStairsWidth,
			PCT_MiddleStairsWidth,
			PCT_TwoRunStairsWidth
		}
	}
}
